package com.hmall.item.web;

/**
 * hm-mall
 * 2024/11/15 17:35
 * SearchController By 1mZ
 */

import com.hmall.common.dto.PageDTO;
import com.hmall.item.pojo.Item;
import com.hmall.item.pojo.RequestParams;
import com.hmall.item.service.IItemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("search")
public class FilterController {
    @Autowired
    private IItemService itemService;
    @PostMapping("/filters")
        public Map<String, List<String>> getFilterOptions(@RequestBody RequestParams requestParams) {
            Map<String, List<String>> filters = itemService.getFilterOptions(requestParams);
            return filters;  // Spring 会自动封装成响应体，状态码默认 200
        }
    @PostMapping("/list")
    public PageDTO<Item> getList(@RequestBody RequestParams requestParams){
            return itemService.searchItems(requestParams);
        }
}

